<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:ds="http://deltaset.org/deltaset-faces"
                xmlns:mf="http://java.sun.com/jsf/composite/deltaset.meta/flow"
                xmlns:p="http://primefaces.org/ui"
                xmlns:composite="http://java.sun.com/jsf/composite"> 


    <p:dataTable var="tableItem" 
                 value="#{metaBean.lazyDataModel}"                               
                 paginator="true" rows="10"               
                 paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                 rowsPerPageTemplate="5,10,15" >

        <c:forEach items="#{metaBean.listFields}" var="field">
            <p:column headerText="#{metaBean.labelField(field, metaBean.modelClass)}">
                <mf:output-list meta="#{metaBean}"
                                field="#{field}" 
                                value="#{tableItem[field.propertyName]}"/>
            </p:column>                       
        </c:forEach>               

        <p:column headerText="id">
            <h:outputText value="#{metaBean.getItemId(tableItem)}" />
        </p:column>

        <p:column headerText="Actions">

            <h:panelGroup>                
                <c:set var="recordId" value="#{metaBean.getItemId(tableItem)}"/>
                <c:set var="itemClassName" value="#{metaBean.getItemClassName(tableItem)}"/>
                <h:commandLink  value="View">
                    <f:ajax event="click" render="@form"/>
                    <f:param name="deltaset.meta.entityClassName" value="#{itemClassName}"/>
                    <f:param name="deltaset.meta.viewName" value="detailTemplate"/>
                    <f:param name="deltaset.meta.recordId" value="#{recordId}"/>
                </h:commandLink>
                <c:forEach items="#{metaBean.contextActions}" var="action">
                    <mf:commandButton metaAction="#{action}"
                                      model="#{tableItem}"
                                      meta="#{metaBean}"
                                      useItemParams="true"
                                      itemId="#{recordId}"
                                      itemClassName="#{itemClassName}"
                                      />                   
                </c:forEach>
                <c:forEach items="#{metaBean.otherContextActions}" var="action">
                    <mf:commandButton metaAction="#{action}"
                                      model="#{tableItem}"
                                      meta="#{metaBean}"
                                      noVoidShow="executeTemplate"
                                      voidShow="executeTemplate"                                          
                                      style="font-size: 0.8em;"
                                      />
                </c:forEach>
            </h:panelGroup>
        </p:column>             

    </p:dataTable>  

</ui:composition>
